home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d1 / batchlrn.arc / FOR.HLP < prev    next >
Text File  |  1991-06-17  |  5KB  |  69 lines

  1.                 * *
  2.                 * *
  3.                 * *
  4.                 * *
  5.                 * *
  6. |---------------B A T C H L R N  H E L P  S Y S T E M-----------------|
  7. |command: FOR                                                         |
  8. |use: The FOR command is used to expand the power of a batch file     |
  9. | command or as an interactive (from the keyboard prompt) command     |
  10. |how: In Batch processing type: FOR %%<c>IN<set>DO<command>           |
  11. |     In Interactive processing type: FOR %<c>IN<set>DO<command>      |
  12. |     (Did you say Huh? You demand...and get, a translation...)       |
  13. |translation: %%<c> or %<c> is a variable. <c> can be any character   |
  14. | except 0,1,2,3...,9. This avoids confusion with the %0-%9 batch pa- |
  15. | ramaters. <set> is a list of items separated by spaces and enclosed |
  16. | in parentheses. For example:: (item1 item2 item3...itemN) is a set. |
  17. | The %%<c> variable is set sequentially to each member of the <set>, |
  18. | and then <command> is performed. If a member of <set> is an express-|
  19. | ion involving either * or ?, or both,  then the varible is set to   |
  20. | each matching pattern from the file. In this case, only one such    |
  21. | <item> may be in the set. Any <item> other than the first <item> is |
  22. | ignored.                                   |
  23. |       (We  KNOW this is  DIFFICULT, but  STAY with us!). . .        |
  24. |explanation: The translation is complex,but UNTIL YOU UNDERSTAND IT, |
  25. | SO is the FOR command. For that reason,AFTER you have finished this |
  26. | .HLP file go to FORINDO.HLP which has examples & explanations(They  |
  27. | are NO GOOD, however, unless you understand the overall concept)!   |
  28. |    The FOR command is similar to the "for..next loop" that programm-|
  29. | ers use to repeat a paricular action a given number of times. The   |
  30. | FOR file to compare files on A: & B: drives looks like this:        |
  31. |    FOR %X IN (*.*) DO IF EXIST B:%X ECHO %X IS ON BOTH A:&B:        |
  32. |    |      |        |=the<command>(here, starting on A:drive, the    |
  33. |    |      |          DO sees IF X {which is *.*[any of all the      |
  34. |    |      |          files on A:]} exists on B: the ECHOes the      |
  35. |    |      |          file name {X} as being on "BOTH A:&B:")        |
  36. |    |      |                                                         |
  37. |    |      |=IN<set> the set is *.* or all the files on A:&B:        |
  38. |    |                                                                |
  39. |    |=FOR is seeking the variable %X (it could be any letter)        |
  40. |                                               |
  41. |            (It should be starting to get clearer)                   |
  42. |    What we have displayed is an interactive FOR command string. If  |
  43. | it were in a two-line batch file (for example) the first line would |
  44. | be ECHO OFF to keep command clutter off the screen. ALSO,in a batch |
  45. | file %X would be %%X (this tells DOS this is NOT a marker. It also  |
  46. | leaves one % after multiple parameter processing {seeFORINDO>HLP}). |
  47. |examples: SEE THE FORINDO.HLP FILE FOR EXAMPLES & EXPLANATIONS!      |
  48. |                                                                     |
  49. |notes: Remember, in a batch file, you must use the expression "%%".  |
  50. | If you are in interactive DOS processing mode,only ONE % is needed. |
  51. | You cannot nest FOR commands in DOS like the FOR-NEXT command is    |
  52. | used in GWBASIC. If you try to do this, the message:                |
  53. |                     "FOR cannot be nested"                          |
  54. | appears when you are running your batch program. The program will   |
  55. | not perform as you expected.                                        |
  56. | (SET) is one or more filenames or commands you want %%Varible to    |
  57. | assume while the command is being executed. Use a space between     |
  58. | entries, and pathnames are not allowed. Don't folrget the parenthe- |
  59. | sis around the set. Wildcards may be used within (SET) if you are   |
  60. | using filenames.                                                    |
  61. | Command is the particular DOS command or batch subcommand you want  |
  62. | to have performed. Usually one or more of these commands will       |
  63. | contain the %%Varible in it. If (SET) contains DOS commands, only   |
  64. | %%Varible is used.                                                  |
  65. | In effect, what this subcommand does is cause %%Varible to be an    |
  66. | index into the (SET) for use by command.                            |
  67. |                                                                     |
  68. |----------------- T  I  M  E  M  A  S  T  E  R  ---------------------|
  69.